<?php


class Module_User_Provisioning
{
    private static $obj = null;
    private $model = null;
    use Lib_BaseTraitsModule;

    /**
     * 封闭构造
     */
    private function __construct()
    {

        $this->model = new Model_User_Provisioning();

    }

    /**
     * 单例获取
     * 保证一条进程只产生一个Module对象
     */
    public static function getInstance()
    {
        if (empty (self::$obj)) {
            self::$obj = new self();;
        }
        return self::$obj;
    }

    /**获取全部数据
     * @return mixed
     */
    public function getListAll()
    {
        return $this->model->getListAll();
    }

    /**
     * @param $id
     * @return mixed
     */
    public function deleteById($id)
    {
        return $this->model->deleteById($id);
    }

    /*
     * 存储数据
     */
    public function insertData($saveData)
    {
        return $this->model->insertData($saveData);
    }

    /**
     * 获取列表
     */
    public function getListByRoleId($role_ids)
    {
       if($role_ids==1){
           return $this->model->getListAll();
       }else{
           $res =  Module_User_Role::getInstance()->getRoleById($role_ids);
           $provisioning = $res['provisioning'];
           return $this->model->getListByRoleId($provisioning);
       }


    }
}